import request from '@/utils/http'
import { useAppStore } from '@/store'

const PATH = '/betting'

export function getMatchs(params: any) {
	return request({
		url: PATH + '/events',
		method: 'get',
		params
	})
}

export function getMatchsByIds(eventIDs: string) {
	const appStore = useAppStore()
	return request({
		url: PATH + '/events',
		method: 'get',
		params: {
			eventIDs,
			locale: appStore.lang,
			oddsStyle: appStore.odds,
			pageSize: 100
		}
	})
}

export function getMatchIds(params: any) {
	return request({
		url: PATH + '/events',
		method: 'get',
		params
	})
}

// 运动列表
export function getSports(params: any) {
	return request({
		url: PATH + '/sports',
		method: 'get',
		params
	})
}
// 联赛列表
export function getLeagues(params: any) {
	return request({
		url: PATH + '/leagues',
		method: 'get',
		params
	})
}
// 地区列表
export function getSportsRegions(params: any) {
	return request({
		url: PATH + '/sports-regions',
		method: 'get',
		params
	})
}

export function getMatchMore(params: any) {
	const { eventId } = params
	return request({
		url: PATH + '/events/' + eventId,
		method: 'get',
		params
	})
}

export function prepareBets(data: any) {
	return request({
		url: PATH + '/prepare-bets',
		method: 'post',
		data
	})
}

export function placeBets(data: any) {
	return request({
		url: PATH + '/place-bets',
		method: 'post',
		data
	})
}

export function closeBet(data: any) {
	return request({
		url: PATH + '/close-bet',
		method: 'post',
		data
	})
}

export function followBets(data: any) {
	return request({
		url: PATH + '/follow-bets',
		method: 'post',
		data
	})
}

export function getBetList(params: any) {
	return request({
		url: PATH + '/bets',
		method: 'get',
		params
	})
}

export function getBetAnalysis(params: any) {
	return request({
		url: PATH + '/bets/data/events/' + params.eventId,
		method: 'get',
		params
	})
}

export function getBetStatistic(params: any) {
	return request({
		url: PATH + '/bets/data/users/' + params.userId,
		method: 'get',
		params
	})
}

export function getBetRecent(params: any) {
	return request({
		url: PATH + '/bets/outcomes',
		method: 'get',
		params
	})
}

export function getUserBets(params: any) {
	const { userId } = params
	return request({
		url: PATH + '/users/' + userId + '/bets',
		method: 'get',
		params
	})
}

export function getFreeBetList() {
	return request({
		url: PATH + '/my-bonuses',
		method: 'get'
	})
}

export function getQuickInputList(params: any) {
	return request({
		url: PATH + '/default-stakes',
		method: 'get',
		params
	})
}

export function getRecommendMatchs(params: any) {
	return request({
		url: PATH + '/recommend-events',
		method: 'get',
		params
	})
}

export function getLeagueEvents(params: any) {
	return request({
		url: PATH + '/outright-events',
		method: 'get',
		params
	})
}

export function getBettingConfigs(params: any) {
	return request({
		url: PATH + '/configs',
		method: 'get',
		params
	})
}

export function getHotLeagues(params: any) {
	return request({
		url: PATH + '/league-hots',
		method: 'get',
		params
	})
}

export function getEventsCount(data: any) {
	return request({
		url: PATH + '/events-count',
		method: 'post',
		data
	})
}

export function getLeagueData(params: any) {
	return request({
		url: PATH + '/leagues',
		method: 'get',
		params
	})
}

export function getBannerList(position: number, region: number, language: string) {
	return request({
		url: PATH + '/ad/list',
		method: 'post',
		data: {
			position,
			location: region,
			locale: language,
			status: 2,
			isClient: true
		}
	})
}

export function getMarkets(params: any) {
	return request({
		url: PATH + '/market-type-rules',
		method: 'get',
		params
	})
}

export function getBetResultDetail(params: any) {
	return request({
		url: PATH + '/bets/orders/' + params.orderNo,
		method: 'get',
		params
	})
}

export function getBetOrdersStatus(params: any) {
	return request({
		url: PATH + '/bets/orders-status',
		method: 'get',
		params
	})
}

export function getCashouts(data: any) {
	return request({
		url: PATH + '/cashouts',
		method: 'post',
		data
	})
}

export function getPendingSum() {
	return request({
		url: PATH + '/pending-sum',
		method: 'get'
	})
}

export const getLiveStream = (params: any) =>
	request({ url: `${PATH}/live-streams/stream-links`, method: 'get', params })
